﻿using Compass.Wasm.Shared.Categories;
using Compass.Wasm.Shared.Plans;
using Zack.DomainCommons.Models;

namespace Compass.PlanService.Domain.Entities;

public record FinishedGoodsCount : AggregateRootEntity, IAggregateRoot, IHasCreationTime, ISoftDelete
{
    public string OdpNumber { get; private set; }//FSO号码
    public string Name { get; private set; }//项目名称
    public Sbu_e Sbu { get; private set; }//
    public int PalletQuantity { get; private set; }//托盘数量
    
    public DateTime FinishTime { get; private set; }//完工时间，合同提货日期
    public DateTime? WarehousingTime { get; private set; }//入库日期
    public DateTime? ShippingTime { get; private set; }//出货日期

    
    public DateTime? OutsideTime { get; private set; } //移至外仓日期
    public double OutsideArea { get; private set; } //外仓货物面积
    public WarehouseLocation_e Location { get; private set; }//库位

    #region ctor
    private FinishedGoodsCount() { }
    public FinishedGoodsCount(Guid id,string odpNumber,string name,Sbu_e sbu,int palletQuantity,DateTime finishTime,DateTime? warehousingTime,DateTime? shippingTime,DateTime? outsideTime,double outsideArea,WarehouseLocation_e location)
    {
        Id = id;
        OdpNumber=odpNumber;
        Name = name;
        Sbu = sbu;
        PalletQuantity = palletQuantity;
        FinishTime = finishTime;
        WarehousingTime=warehousingTime;
        ShippingTime=shippingTime;
        OutsideTime = outsideTime;
        OutsideArea=outsideArea;
        Location=location;
    }
    #endregion

    #region Update
    public void Update(FinishedGoodsCountDto dto)
    {
        ChangeOdpNumber(dto.OdpNumber)
            .ChangeName(dto.Name)
            .ChangeSub(dto.Sbu)
            .ChangePalletQuantity(dto.PalletQuantity)
            .ChangeFinishTime(dto.FinishTime)
            .ChangeWarehousingTime(dto.WarehousingTime)
            .ChangeShippingTime(dto.ShippingTime)
            .ChangeOutsideTime(dto.OutsideTime)
            .ChangeOutsideArea(dto.OutsideArea)
            .ChangeLocation(dto.Location);
        NotifyModified();
    }
    public FinishedGoodsCount ChangeOdpNumber(string odpNumber)
    {
        OdpNumber = odpNumber;
        return this;
    }
    public FinishedGoodsCount ChangeName(string name)
    {
        Name = name;
        return this;
    }
    public FinishedGoodsCount ChangeSub(Sbu_e sbu)
    {
        Sbu = sbu;
        return this;
    }
    public FinishedGoodsCount ChangePalletQuantity(int palletQuantity)
    {
        PalletQuantity = palletQuantity;
        return this;
    }
    public FinishedGoodsCount ChangeFinishTime(DateTime finishTime)
    {
        FinishTime = finishTime;
        return this;
    }
    public FinishedGoodsCount ChangeWarehousingTime(DateTime? warehousingTime)
    {
        WarehousingTime = warehousingTime;
        return this;
    }
    public FinishedGoodsCount ChangeShippingTime(DateTime? shippingTime)
    {
        ShippingTime = shippingTime;
        return this;
    }
    public FinishedGoodsCount ChangeOutsideTime(DateTime? outsideTime)
    {
        OutsideTime = outsideTime;
        return this;
    }
    public FinishedGoodsCount ChangeOutsideArea(double outsideArea)
    {
        OutsideArea = outsideArea;
        return this;
    }
    public FinishedGoodsCount ChangeLocation(WarehouseLocation_e location)
    {
        Location = location;
        return this;
    }
    #endregion



}